package com.moli.iov.handle.alarm.biz.real;

import com.moli.iov.async.BlockingQueueThreadPool;
import com.moli.iov.handle.alarm.biz.real.extend.platform.BatteryVoltageReal;
import com.moli.iov.handle.alarm.biz.real.extend.platform.SocReal;
import com.moli.iov.handle.alarm.model.dto.AuthDto;
import com.moli.iov.protocol.model.realtime.RealTimeInfoReq;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>
 *
 * 实时平台判断 （蓄电池低电压报警、SOC电压低报警）
 *
 * </p>
 *
 * @author: zql
 * @Date: 2019/2/15 9:28
 */
@Slf4j
@Component
public class PlatformJudgmentReal {

    @Autowired
    private BatteryVoltageReal batteryVoltageReal;

    @Autowired
    private SocReal socReal;

    @Autowired
    private FenceReal fenceReal;

    @Resource(name = "fenceRealBlockingQueueThreadPool")
    private BlockingQueueThreadPool blockingQueueThreadPool;

    public void handle(RealTimeInfoReq realTimeInfoReq, AuthDto authDto){
        try{

            batteryVoltageReal.handle(realTimeInfoReq.vin, realTimeInfoReq, authDto);

            socReal.handle(realTimeInfoReq.vin, realTimeInfoReq, authDto);

            blockingQueueThreadPool.execute(realTimeInfoReq.vin, () ->
                fenceReal.handle(realTimeInfoReq, authDto));

        }catch(Exception e){
            log.error("实时平台判断 （进出区域报警、蓄电池低电压报警、SOC电压低报警）异常", e);
        }
    }

}
